package com.xyd.Servlet;

import com.xyd.Biz.Impl.ProductCarBizImpl;
import com.xyd.Biz.ProductCarBiz;
import com.xyd.Entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @ClassName: UpdateProductCarServlet
 * @Description:更新购物车中商品信息
 * @Author 余全盛
 * @Date: 2021/10/16 14:21
 */
@WebServlet("/UpdateProductCarServlet")
public class UpdateProductCarServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ProductCarBiz productCarBiz = new ProductCarBizImpl();
        HttpSession session=req.getSession();
        int productId = Integer.parseInt(req.getParameter("productid") == null || "".equals(req.getParameter("productid")) ? "0" : req.getParameter("productid"));
        int num = Integer.parseInt(req.getParameter("num") == null || "".equals(req.getParameter("num")) ? "0" : req.getParameter("num"));
        User user=(User) session.getAttribute("user");
        productCarBiz.updateProductCar(productId, num, user.getUserid());

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
